<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta charset="utf-8"/>
  <link rel="stylesheet" href="__ADMIN__/ace/css/ui.jqgrid.css" />
  <meta name="keywords" content="{$Think.CONFIG.keywords}"/>
  <meta name="description" content="{$Think.CONFIG.description}"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

  {include file="public/head" /}

</head>
<body>
<div class="main-container" id="main-container">
  <script type="text/javascript">
    try {
      ace.settings.check('main-container', 'fixed')
    } catch (e) {
    }
  </script>

  <div class="main-container-inner">
    <a class="menu-toggler" id="menu-toggler" href="#">
      <span class="menu-text"></span>
    </a>

    {include file="public/nav"/}

    {include file="public/menu"/}

    <div class="main-content">
      {include file="public/breadcrumb"/}

      <div class="page-content">
        <div class="row">
          <div class="cf">
            <a class="btn btn-info" href="{:Url('add')}">新增</a>
          </div>
          <table id="tbFleet">
          </table>
          <div id="tbFleetPager"></div>
        </div><!-- /.row -->
      </div><!-- /.page-content -->
    </div><!-- /.main-content -->

  </div><!-- /.main-container-inner -->

  <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="fa fa-angle-double-up fa-only bigger-110"></i>
  </a>
</div>
</body>
{include file="public/footerjs"/}
<script src="__ADMIN__/ace/js/bootbox.min.js"></script>
<script src="__ADMIN__/ace/js/jqGrid/i18n/grid.locale-cn.js"></script>
<script src="__ADMIN__/ace/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="__ADMIN__/js/ittaoli.js"></script>
<script>
  (function () {
    car = {
      edit: function (url) {
        location.href=url;
      },
      del: function (car_num) {
        $.post("{:url('del')}", {car_num: car_num}, function (data) {
          if (data > 0) {
            bootbox.alert("删除成功");
            setTimeout(function () {
              location.reload();
            }, 1000)
          } else {
            bootbox.alert("删除失败");
          }
        })
      }
    };

    // 初化表格
    var $path_base="/";

    var grid_data =
      [
        {id:"1",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FedEx", sdate:"2007-12-03"},
        {id:"2",name:"Laptop",note:"Long text ",stock:"Yes",ship:"InTime",sdate:"2007-12-03"},
        {id:"3",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TNT",sdate:"2007-12-03"},
        {id:"4",name:"Speakers",note:"note",stock:"No",ship:"ARAMEX",sdate:"2007-12-03"},
        {id:"5",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FedEx",sdate:"2007-12-03"},
        {id:"6",name:"Play Station",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"},
        {id:"7",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"ARAMEX",sdate:"2007-12-03"},
        {id:"8",name:"Server",note:"note2",stock:"Yes",ship:"TNT",sdate:"2007-12-03"},
        {id:"9",name:"Matrix Printer",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"},
        {id:"10",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FedEx", sdate:"2007-12-03"},
        {id:"11",name:"Laptop",note:"Long text ",stock:"Yes",ship:"InTime",sdate:"2007-12-03"},
        {id:"12",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TNT",sdate:"2007-12-03"},
        {id:"13",name:"Speakers",note:"note",stock:"No",ship:"ARAMEX",sdate:"2007-12-03"},
        {id:"14",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FedEx",sdate:"2007-12-03"},
        {id:"15",name:"Play Station",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"},
        {id:"16",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"ARAMEX",sdate:"2007-12-03"},
        {id:"17",name:"Server",note:"note2",stock:"Yes",ship:"TNT",sdate:"2007-12-03"},
        {id:"18",name:"Matrix Printer",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"},
        {id:"19",name:"Matrix Printer",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"},
        {id:"20",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FedEx", sdate:"2007-12-03"},
        {id:"21",name:"Laptop",note:"Long text ",stock:"Yes",ship:"InTime",sdate:"2007-12-03"},
        {id:"22",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TNT",sdate:"2007-12-03"},
        {id:"23",name:"Speakers",note:"note",stock:"No",ship:"ARAMEX",sdate:"2007-12-03"}
      ];

    var grid_selector = "#tbFleet";
    var pager_selector = "#tbFleetPager";

    $(grid_selector).jqGrid({
      //direction: "rtl",

      data: grid_data,
      datatype: "local",
      height: 250,
      colNames:[' ', 'ID','Last Sales','Name', 'Stock', 'Ship via','Notes'],
      colModel:[
        {name:'myac',index:'', width:80, fixed:true, sortable:false, resize:false,
          formatter:'actions',
          formatoptions:{
            keys:true,

//            delOptions:{recreateForm: true, beforeShowForm:beforeDeleteCallback},
            //editformbutton:true, editOptions:{recreateForm: true, beforeShowForm:beforeEditCallback}
          }
        },
        {name:'id',index:'id', width:60, sorttype:"int", editable: true},
        {name:'sdate',index:'sdate',width:90, editable:true, sorttype:"date",unformat: pickDate},
        {name:'name',index:'name', width:150,editable: true,editoptions:{size:"20",maxlength:"30"}},
        {name:'stock',index:'stock', width:70, editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"},unformat: aceSwitch},
        {name:'ship',index:'ship', width:90, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},
        {name:'note',index:'note', width:150, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"10"}}
      ],

      viewrecords : true,
      rowNum:10,
      rowList:[10,20,30],
      pager : pager_selector,
      altRows: true,
      //toppager: true,

      multiselect: true,
      //multikey: "ctrlKey",
      multiboxonly: true,

      loadComplete : function() {
        var table = this;
//        setTimeout(function(){
//          styleCheckbox(table);
//
//          updateActionIcons(table);
//          updatePagerIcons(table);
//          enableTooltips(table);
//        }, 0);
      },

      editurl: $path_base+"/dummy.html",//nothing is saved
      caption: "jqGrid with inline editing",


      autowidth: true

    });
  }());
  //switch element when editing inline
  function aceSwitch( cellvalue, options, cell ) {
    setTimeout(function(){
      $(cell) .find('input[type=checkbox]')
        .wrap('<label class="inline" />')
        .addClass('ace ace-switch ace-switch-5')
        .after('<span class="lbl"></span>');
    }, 0);
  }

  function pickDate( cellvalue, options, cell ) {
    setTimeout(function(){
      $(cell) .find('input[type=text]')
        .datepicker({format:'yyyy-mm-dd' , autoclose:true});
    }, 0);
  }
</script>

{include file="public/foot" /}
